fix: add parent-directory permission checks to rename()#340
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: add parent-directory permission checks to rename()#340toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
POSIX rename(2) requires write+execute permission on both the source
and destination parent directories. All other directory-modifying
operations (unlink, mkdir, rmdir) already enforced this via
_check_parent_perms(), but rename was missing the check entirely.
With set_user() active, rename('/protected/src/f', '/dst/f') would
succeed even when the source parent was read-only — now it correctly
returns EACCES.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add missing write+execute permission checks on both parent directories in
rename().Why
POSIX rename(2) requires write+execute on both the source and destination parent directories. Every other directory-modifying operation (
unlink,mkdir,rmdir) already enforced this via_check_parent_perms(), butrenamewas missing the check entirely. Withset_user()active,rename('/protected/src/file', '/dst/file')would succeed even when the source parent was 0555 — now it correctly returns EACCES.How
Added
_check_parent_perms($mock_old->{'path'}, 2|1)and_check_parent_perms($mock_new->{'path'}, 2|1)checks after the self-rename no-op shortcut, following the same pattern used byunlink,mkdir, andrmdir.Testing
t/rename.t: source parent read-only (EACCES), dest parent read-only (EACCES), both parents writable (success)fh-ref-leak.tfailure)🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 55 insertions(+), 1 deletion(-)
Code scan: clean
Tests: failed (4 Failed, 94 test)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline